package com.acme.bankapp.domain.bank;

import com.acme.exceptions.NotEnoughFundsException;

public class SavingsAccount extends AbstractAccount {

	public SavingsAccount(int balance) {
		super(balance);
	}

	@Override
	public String toString() {
		return "SavingsAccount [id = " + getId() + ", balance=" + getBalance() + "]";
	}

	@Override
	public double getMaximumAmountToWithdraw() {
		return getBalance();
	}

	@Override
	public void deposit(double amount) {
	    if (amount < 0) {
	        throw new IllegalArgumentException();
	    }			
		setBalance(getBalance() + amount);

	}
	
	@Override
	public void withdraw(double amount) throws NotEnoughFundsException {
	    if (amount < 0) {
	        throw new IllegalArgumentException();
	    }			
		if (amount >= getBalance()) {
		    throw new NotEnoughFundsException(amount);
		}
		setBalance(getBalance() - amount);
	}


}
